package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.dto.RoomDto;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectVo;
import com.zzyl.vo.RoomVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import static com.zzyl.base.ResponseResult.success;

@RestController
@RequestMapping("/nursing_project")
@Api(tags = "护理模块接口")
public class NursingProjectController {
    @Autowired
    private NursingProjectService nursingProjectService;

    @GetMapping
    @ApiOperation(value = "分页查询护理项目")
    public ResponseResult<NursingProjectVo> PageNursing(String name, Integer pageNum, Integer pageSize, Integer status) {
        PageResponse<NursingProjectVo> pageInfo = nursingProjectService.PageNursing(name, pageNum, pageSize, status);
        return success(pageInfo);
    }

   @PostMapping
    @ApiOperation( "添加护理项目")
    public ResponseResult addNursingProject(@RequestBody NursingProjectDto nursingProjectDto) {
        nursingProjectService.addNursingProject(nursingProjectDto);
        return success();
    }
    @GetMapping("/{id}")
    @ApiOperation("根据id查询护理")
    public ResponseResult<NursingProjectVo> getNursing(@PathVariable Long id) {
        NursingProjectVo nursingProjectVo = nursingProjectService.getNursing(id);
        return success(nursingProjectVo);
    }
    @PutMapping
    @ApiOperation("修改护理项目")
    public ResponseResult updateNursingProject(@RequestBody NursingProjectDto nursingProjectDto) {
        nursingProjectService.updateNursing(nursingProjectDto);
        return success();
    }
    @DeleteMapping("/{id}")
    @ApiOperation("删除护理项目")
    public ResponseResult deleteNursingProject(@PathVariable Long id) {
        nursingProjectService.deleteNursing(id);
        return success();
    }
    @GetMapping("/all")
    @ApiOperation("查询所有护理项目")
    public ResponseResult<NursingProjectVo> getAllNursingProject() {
        return success(nursingProjectService.getAllNursingProject());
    }
    @PutMapping("/{id}/status/{status}")
    @ApiOperation("启用/禁用护理项目")
    public ResponseResult enableOrDisable(
            @ApiParam(value = "护理项目ID", required = true) @PathVariable Long id,
            @ApiParam(value = "护理项目状态", required = true) @PathVariable Integer status) {
        nursingProjectService.modifyState(id, status);
        return success();
    }
}
